#!/bin/bash

set -e

rm -rf bin
mkdir -p tmp
cleanup_exit() {
  echo "Test failed" ${2}
  exit ${1}
}

echo "Build should fail"
../../build.py build ... > tmp/output 2>&1 && cleanup_exit 1 "build :a #1 succeded"
cat tmp/output

# Expect to see the target name, and the line number, and the word BUILD
cat tmp/output | grep "//:a" || cleanup_exit 1 'bad output 1.'
cat tmp/output | grep "3" || cleanup_exit 1 'bad output 2.'
cat tmp/output | grep "BUILD" || cleanup_exit 1 'bad output 3.'

rm -rf bin
rm -rf tmp

echo 'Test passed'
